﻿@page "/listener/{ListenerId:int}/hostedfile"
@attribute [Authorize(Roles = "User, Administrator")]
@inherits OwningComponentBase<ICovenantService>

@using Covenant.Core
@using Covenant.Models.Listeners

<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3">
    <h1 class="h2">HostedFiles</h1>
</div>

<HostedFileTable HostedFiles="HostedFiles" />
<a href="/listener/@ListenerId/hostedfile/create" class="btn btn-primary">
    <span class="fe fe-plus"></span>
    Create
</a>

@code {
    [Parameter]
    public int ListenerId { get; set; }

    [Parameter]
    public IEnumerable<HostedFile> HostedFiles { get; set; }

    protected override async Task OnInitializedAsync()
    {
        this.HostedFiles = this.HostedFiles ?? await Service.GetHostedFilesForListener(ListenerId);
    }
}